package com.samphanie.auiu.common.constants;

/**
 * @author ZSY
 * @email 1451691457@qq.com
 */
public class AuiuConstants {

    public static final String DEFAULT_EMAIL_ADDRESS = "1451691457@qq.com";

    public static final String PROBLEM_BASE_URI = "https://www.auiucloud.com";
    // ---- 正则表达式相关 ----
    public static final String PATTERN_MOBILE = "^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\\d{8}$";
    public static final String PATTERN_USERNAME = "^[a-z0-9_-]{3,50}$";
    public static final String PATTERN_ROLE_NAME = "^[a-zA-Z0-9_]{3,50}$";

    // 后台管理client_id
    public static final String ADMIN_CLIENT_ID = "admin-app";
    // 前台商城client_id
    public static final String PORTAL_CLIENT_ID = "portal-app";

    // 后台管理接口路径匹配
    public static final String ADMIN_URL_PATTERN = "/auiu-admin/**";
    // 仅支持字母、数字、下划线、空格、逗号、小数点（支持多个字段排序
    public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+";
    // ---- 授权相关 ----
    public static final String JWT_TOKEN_PREFIX = "Bearer ";
    public static final String JWT_TOKEN_HEADER = "Authorization";
    // 用户信息Http请求头
    public static final String USER_TOKEN_HEADER = "user";
    // Redis缓存权限规则key
    public static final String RESOURCE_ROLES_MAP_KEY = "auth:resourceRolesMap";

    // JWT存储权限属性
    public static final String AUTHORITY_CLAIM_NAME = "authorities";
    public static final String ROLE_PREFIX = "ROLE_";
    public static final String AUTHORITY_USER = "USER";
    public static final String AUTHORITY_STAFF = "STAFF";
    public static final String AUTHORITY_MANAGER = "MANAGER";
    public static final String AUTHORITY_ADMIN = "ADMIN";
    public static final String ROLE_USER = ROLE_PREFIX + AUTHORITY_USER;
    public static final String ROLE_STAFF = ROLE_PREFIX + AUTHORITY_STAFF;
    public static final String ROLE_MANAGER = ROLE_PREFIX + AUTHORITY_MANAGER;
    public static final String ROLE_ADMIN = ROLE_PREFIX + AUTHORITY_ADMIN;
    public static final String AUTHORITY_USER_ADMIN = "USER_ADMIN";
    public static final String AUTHORITY_USER_UPDATE = "USER_UPDATE";
    public static final String AUTHORITY_USER_CREATE = "USER_CREATE";
    public static final String AUTHORITY_USER_READ = "USER_READ";
    // ---- 缓存相关 ----
    public static final String CACHE_MFA = "cacheMfa";
    public static final String CACHE_ALL_PERMISSIONS = "cacheAllPermissions";
    public static final String CACHE_ALL_ROLES = "cacheAllRoles";

    /*** 当前页码 */
    public static final String PAGE = "pageNum";
    /*** 每页显示记录数 */
    public static final String LIMIT = "pageSize";
    /*** 排序字段 */
    public static final String ORDER_FIELD = "sidx";
    /*** 排序方式 */
    public static final String ORDER = "order";
    /*** 升序 */
    public static final String ASC = "asc";
    /*** 降序 */
    public static final String DESC = "desc";

    /**
     * Redis所有Keys
     */
    public static String getSysConfigKey(String key){
        return "sys:config:" + key;
    }

}
